﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using RAgency.Model;
using System.Configuration;

namespace RAgency.Manager
{
    public partial class MProfiles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void AddButton_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
            try
            {
                Profile obj = new Profile();
                obj.Education = education_d.Text;
                obj.Speciality = speciality.Text;
                obj.Exp = Convert.ToInt32(exp.Text);
                obj.Duty = duty_d.Text;
                obj.Payment = Convert.ToInt32(payment.Text);
                obj.Age = Convert.ToInt32(age.Text);

                conn.Open();
                SqlCommand comm = new SqlCommand("insert into profile (education, speciality, exp, duty, payment, age, createdate) values (@x3,@x4,@x5,@x6,@x7,@x8,@x9)", conn);
                comm.Parameters.Add("@x3", System.Data.SqlDbType.NVarChar).Value = obj.Education;
                comm.Parameters.Add("@x4", System.Data.SqlDbType.NVarChar).Value = obj.Speciality;
                comm.Parameters.Add("@x5", System.Data.SqlDbType.Int).Value = obj.Exp;
                comm.Parameters.Add("@x6", System.Data.SqlDbType.NVarChar).Value = obj.Duty;
                comm.Parameters.Add("@x7", System.Data.SqlDbType.Int).Value = obj.Payment;
                comm.Parameters.Add("@x8", System.Data.SqlDbType.Int).Value = obj.Age;
                comm.Parameters.Add("@x9", System.Data.SqlDbType.DateTime).Value = DateTime.Now;
                SqlDataReader r = comm.ExecuteReader();
                inv.DataBind();
            }
            catch (Exception ex)
            {
                ErrLabel.Text = ex.Message;
            }
            finally
            {
                conn.Close();
                speciality.Text = "";
                exp.Text = "";
                payment.Text = "";
                age.Text = "";
            }
        }
    }
}